<?php
require_once 'mods/class_repair_file.php';

$id = intval($_GET['id']);
if ($id)
{
    $objRepairFile = new RepairFile();

    if ($objRepairFile->load($id))
    {
        $name = $objRepairFile->file;
        $size = $objRepairFile->getFile()->size;
        $type = $objRepairFile->getFile()->type;
        $realFileName = $objRepairFile->getFile()->name;

        $fileBigPath = $objRepairFile->getFilePath();
        if (file_exists($fileBigPath))
        {
            header("Content-Type: '{$type}%>; charset=windows-1251");
            header("Content-Disposition: attachment; filename=\"{$realFileName}\"");
            header("Content-Transfer-Encoding: binary");
            header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
            header("Pragma: public");
            header("Content-Length: {$size}");
            header("Expires: 0");
            readfile($fileBigPath);
        }
    }
}
